import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
import { UserGetListModel, UserCreateModel, UserModel } from './model/userModel';

/**
 * @description: 创建用户
 */
export function createUserApi(params: UserCreateModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<UserModel>(
    {
      url: '/user',
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function getUserListApi(params: UserGetListModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<Array<UserModel>>(
    {
      url: '/user',
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function deleteUserApi(id: number) {
  return defHttp.delete({
    url: `/user${'/' + id}`,
  });
}
